<?php
/**
 * Created by PhpStorm.
 * User: junyv
 * Date: 2017/4/20
 * Time: 9:07
 */

namespace app\manage\controller;


class SecondEntrust extends Base
{
    //搜索
    public function _search(){
        $map = array();
        $time_start = input('get.time_start');
        $time_end = input('get.time_end');
        if($time_start && !$time_end){
            $map['create_time'] = ['egt',strtotime($time_start)];
        }elseif($time_end && $time_end){
            $map['create_time'] = ['between',[strtotime($time_start),strtotime($time_end)+86399]];
        }
        ($keyword = input('get.keyword')) && $map['title'] = ['like', '%'.$keyword.'%'];
        $status = -1;
        if(isset($_GET['status']) && $_GET['status'] !== ''){
            $status = input('get.status/d');
        }
        $status>=0 && $map['status'] = ['eq',$status];
        $spid = '';
        $area         = input('get.area');
        if(strpos($area,',')!==FALSE){
            $area_arr    = explode(',',$area);
            $map['area'] = $area_arr[1];
            $spid        = str_replace(',','|',$area);
        }elseif(!empty($area)){
            $map['city'] = $area;
            $spid        = $area;
        }
        $this->assign('search', array(
            'time_start' => $time_start,
            'time_end' => $time_end,
            'selected_ids' => $spid,
            'status'  => $status,
            'keyword' => $keyword
        ));
        return $map;
    }
}